home *** CD-ROM | disk | FTP | other *** search
- Path: hp.fciencias.unam.mx!usenet
- From: Heinz Hemken <hhemken@cell.cinvestav.mx>
- Newsgroups: comp.lang.c++
- Subject: newbie ? on inheritance in VC++
- Date: Wed, 10 Jan 1996 16:56:07 -0800
- Organization: An extremely well-installed InterNetNews site
- Message-ID: <30F46027.15FB@cell.cinvestav.mx>
- NNTP-Posting-Host: tamayo.cell.cinvestav.mx
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (X11; I; IRIX 5.3 IP22)
- CC: hhemken@cell.cinvestav.mx
-
- When I compile the following fragment in VC++ 1.5, it says that
- ListHead->Previous 'cannot access protected member function' (see line
- preceded by // ***********************************). C_LIst is derived
- from C_Item, and therefore the protected variables Previous and Next
- should be visible to it, shouldn't they?
-
- = = = = = = = = = = Code Fragment = = = = = = = = = = = = = = = = = =
-
- class C_Item
- {
- protected:
- C_Item *Previous; // address of previous C_Item
- C_Item *Next; // address of next C_Item
- public:
- C_Item();
- ~C_Item();
- C_Item *Attach(C_Item *ItemPointer);
- C_Item *Detach(void);
- };
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // C_List is the base class of a C_List of listable items derived from
- C_Item
-
- class C_List : public C_Item
- {
- private:
- C_Item *ListHead; // C_List head
- C_Item *CurrentItem; // Current C_Item
-
- public:
- // Constructor and destructor
- C_List();
- virtual ~C_List();
- // Inline member functions
- int IsEmpty(void) { return (ListHead == NULL); }
- int IsHead(void)
- {return ((ListHead != NULL) && (CurrentItem ==
- ListHead));}
- int IsEnd(void)
- // ***********************************
- {return ((ListHead != NULL) && (CurrentItem ==
- ListHead->Previous));}
- C_Item *GetCurrentItem(void) { return CurrentItem; }
- C_Item *GetFirstItem(void) { return (CurrentItem = ListHead);}
- void ResetList(void) { CurrentItem = ListHead; }
- void SetCurrentItem(C_Item *ItemPointer) { CurrentItem =
- ItemPointer; }
- // Other member functions
- C_Item *InsertItem(C_Item *ItemPointer);
- C_Item *RemoveItem(C_Item *ItemPointer);
- C_Item *PreviousItem(void);
- C_Item *NextItem(void);
- // Virtual member function
- virtual void DisposeOfList(void);
- };
-
-
- --
- Heinz Hemken
- Departamento de Biologia Celular, CINVESTAV-IPN
- http://www.cell.cinvestav.mx/bchh.html
-